{extend name='layouts/app'/}
{block name='content'}
<ul class="breadcrumb no-border no-radius b-b b-light pull-in">
    <li><a href="{:url('admin/index/index')}"><i class="fa fa-home"></i> 主页</a></li>
    <li class="active">轮播管理</li>
</ul>
<div class="m-b-md">
    <h3 class="m-b-none">轮播列表</h3>
</div>
<ul class="nav nav-tabs list-group">
    <li><a href="{:url('admin/banner/index')}">轮播列表</a></li>
    <li class="active"><a href="javascript:void(0);">新增轮播</a></li>
</ul>
<section class="panel panel-default">
    <header class="panel-heading"> 新增轮播</header>
    <div class="panel-body">
        <form class="form-horizontal" action="{:url('admin/banner/store')}" method="post">
            <div class="form-group">
                <label class="col-sm-2 control-label">标题</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="title" placeholder="输入标题">
                </div>
            </div>
            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <label class="col-sm-2 control-label">缩略图</label>
                <div class="col-sm-10">
                    <div class="input-group">
                        <input type="hidden" class="form-control" name="thumb" readonly="" value="">
                        <div class="group-btn">
                            <button onclick="upImage(this)" class="btn btn-default" type="button">上传缩略图</button>
                        </div>
                    </div>
                    <div class="input-group" style="margin-top:5px;">
                        <img src="__STATIC__/admin/images/nopic.jpg" class="img-responsive img-thumbnail" width="150">
                        <em class="close" style="position:absolute; top: 0px; right: -14px;" title="删除这张图片" onclick="removeImg(this)">×</em>
                    </div>
                </div>
            </div>
            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <label class="col-sm-2 control-label">链接</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="url" placeholder="输入链接">
                </div>
            </div>
            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <label class="col-sm-2 control-label">排序</label>
                <div class="col-sm-10">
                    <input type="number" class="form-control" name="sort" value="100" placeholder="输入排序">
                </div>
            </div>
            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <label class="col-sm-2 control-label">状态</label>
                <div class="col-sm-10">
                    <div class="radio">
                        <label class="radio-custom m-r-lg">
                            <input type="radio" name="status" value="0" checked="checked"><i class="fa fa-circle-o"></i> 开启
                        </label>
                        <label class="radio-custom">
                            <input type="radio" name="status" value="1"><i class="fa fa-circle-o"></i> 关闭
                        </label>
                    </div>
                </div>
            </div>
            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-2">
                    <button type="submit" class="btn btn-primary">新增</button>
                </div>
            </div>
        </form>
    </div>
</section>
{/block}
{block name='script'}
<script type="text/javascript">
    //上传图片
    function upImage(obj) {
        require(['util'], function (util) {
            options = {
                multiple: false,//是否允许多图上传
                //data是向后台服务器提交的POST数据
                data: {name: '图片', year: 2099},
            };

            util.image(function (images) {
                //上传成功的图片，数组类型
                $("[name='thumb']").val(images[0]);
                $(".img-thumbnail").attr('src', images[0]);
            }, options)
        });
    }

    //移除图片
    function removeImg(obj) {
        $(obj).prev('img').attr('src', "__STATIC__/admin/images/nopic.jpg");
        $(obj).parent().prev().find('input').val('');
    }
</script>
{/block}